package entity

import (
	"strconv"
	"time"

	"shqsoft.cn/pasnj/base"
	"shqsoft.cn/pasnj/bi/cube"
)

type CM_DS_GRLC struct {
	Xsye    *float64   `gorm:"column:销售金额"`
	Ye      *float64   `gorm:"column:余额"`
	Xsrq    *time.Time `gorm:"column:销售日期;type:date;"`
	Qxr     *time.Time `gorm:"column:起息日;type:date;"`
	Dqr     *time.Time `gorm:"column:到期日;type:date;"`
	ID      int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	Khmc    string     `gorm:"column:客户名称;size:20"`
	Cpbh    string     `gorm:"column:产品编号;size:20"`
	Sscp    string     `gorm:"column:所属产品;size:20"`
	Lclx    string     `gorm:"column:理财类型;size:20"`
	Sfzh    string     `gorm:"column:身份证号;size:20"`
	Zhohao  string     `gorm:"column:帐号;size:20"`
	Khao    string     `gorm:"column:卡号;size:20"`
	Yxbz    string     `gorm:"column:有效标志;size:20"`
	Bizhong string     `gorm:"column:币种;size:20"`
	Blwd    string     `gorm:"column:办理网点;size:20"`
	ACID    int        `gorm:"column:ACID"`
	YG1     string     `gorm:"-"`
	ZB1     *float64   `gorm:"-"`
	YG2     string     `gorm:"-"`
	ZB2     *float64   `gorm:"-"`
	YG3     string     `gorm:"-"`
	ZB3     *float64   `gorm:"-"`
}

//TableName 卡号表名
func (CM_DS_GRLC) TableName() string {
	return "V_对私_理财"

}

// AfterFind 选择男女
func (c *CM_DS_GRLC) AfterFind() (err error) {
	var share *cube.Share
	share, err = cube.GetShare("indi_acco_divi")
	if err != nil {
		return
	}
	var diviMap map[string]float64
	diviMap, err = share.GetDivision(strconv.Itoa(c.ACID))
	if err != nil {
		return
	}
	i := 0
	for k, v := range diviMap {
		val := v
		i++
		switch i {
		case 1:
			c.YG1 = k
			c.ZB1 = &val
		case 2:
			c.YG2 = k
			c.ZB2 = &val
		case 3:
			c.YG3 = k
			c.ZB3 = &val
		default:
			break
		}
	}
	return
}

//CM_DS_GRLCEF 个人理财
func CM_DS_GRLCEF() base.EntityFunc {
	return func() interface{} {
		entity := CM_DS_GRLC{}
		return &entity
	}
}

//CM_DS_GRLCESF 个人理财
func CM_DS_GRLCESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []CM_DS_GRLC
		return &entities
	}
}
func init() {
	dao := base.NewDefaultDao(CM_DS_GRLCEF(), CM_DS_GRLCESF(), nil)
	filter := base.DefaultFilter{
		FilterColName: "ACID",
		TableName:     "T_INDI_ACCO_DIVI",
		EmidColName:   "emid",
		AcidColName:   "ACID",
		WhereCause:    "ISWO=0 AND WODT IS NULL",
	}
	dao.Fileter = &filter
	base.DaoPoolObj.Put("CM_DS_GRLC", dao)

}
